package com.orchard.xpz.controller.gardenMedication;

import com.orchard.xpz.entity.GardenFer.GardenFer;
import com.orchard.xpz.entity.GardenMedication.GardenMedication;
import com.orchard.xpz.service.gardenMedication.GardenMedicationService;
import com.orchard.xpz.utils.PageResultData;
import com.orchard.xpz.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @TaskCode:
 * @description:
 * @author: minshuai.chen
 * @create: 2022/4/19 11:05
 **/
@RestController
@RequestMapping("/gardenMed")
public class GardenMedicationController {


    @Autowired
    private GardenMedicationService gardenMedicationService;

    @RequestMapping("/getPageList")
    public R<PageResultData<GardenMedication>> getPageList(@RequestBody GardenMedication gardenMedication){
        return R.success(gardenMedicationService.getPageList(gardenMedication));
    }

    @RequestMapping("/saveOrUpdate")
    public R<String> saveOrUpdate(@RequestBody GardenMedication gardenPlot){
        if (gardenMedicationService.saveOrUpdate(gardenPlot)){
            return R.success("success");
        }else{
            return R.fail("error");
        }
    }

    @RequestMapping("/delete")
    public R<String> delete(@RequestParam("id") String id){
        if (gardenMedicationService.deltePlot(id)){
            return R.success("success");
        }else{
            return R.fail("error");
        }
    }
}
